<?php
/**
 * More & Original PHP Framwork
 * Copyright (c) 2009 - 2010 IsMole Inc.
 * document ConfMaker 配置生成模块
 * $Id: ConfMaker_demo.php starten $
 */
class Control_ExcelConfMaker_createGift {
	var $theConf 	= array();
	var $fileName 	= 'gm_gift.xls';
	var $tpl 		= ''; // 生成配置文件的模板
	var $confPHPTpl = '<?php
$CONF = ';
	
	public function createGift() {	

		$res = $this->setConf();
		
		return $res;
	}
	
	// 处理
	public function setConf() {
		$replace = array();
		$replace[] = '{name}';
		$replace[] = '{confId}';
		
		$file 	= ROOT_PATH . $this->OBJ->excelDir . $this->fileName;
		// ios 
		$gifts 	= MooObj::get('Control_ExcelConfMaker_Excel')->read($file, 'UTF-8', 0);		
		
		$giftCon = array();
		if($gifts) {
			foreach ($gifts as $key => $val) {
				$giftCon[$val['platfrom']] = $val['serverId'];
			}
		}
		
		var_dump($giftCon);
		
		$confTpl = $this->confPHPTpl . format_array_to_string_byStarten($giftCon);		
		
		var_dump($confTpl);
		
		MooFile::write(ROOT_PATH . '/conf/gm_gift.conf.php', $confTpl);
// 		MooView::set('confTpl', highlight_string($confTpl, true));
		
		return $result;
	}
}